<template>
  <div>
    <VipZone/>
    <SelectorPub/>
    <OrderContainer @sales="sales" @compRehen="compRehen" @pageView="pageView" @priceUp="priceUp" @priceDown="priceDown" @releaseTime="releaseTime"/>
    <!--  视频列表-->
    <VideoList :recommendList="recommendList" :bol="true"/>
  </div>

</template>

<script lang="ts">
import {defineComponent} from "vue";
import SelectorPub from "@/views/course/components/selector/index.vue";
import OrderContainer from "@/views/course/components/ordercontainer/index.vue";
import VipZone from "@/views/course/components/vipzone/index.vue";
export default defineComponent({
  name: "member",
  components: {SelectorPub,OrderContainer,VipZone },
});
</script>

<script setup lang="ts">
//初始化挂载时调用
import {onMounted, ref} from "vue";
import {reqRecommend} from "@/apis/source";

onMounted(()=>{
  getRecommendList()
})
//pageSize
const pageSize = ref<number>(10)
//pageNum
const pageNum = ref<number>(0)
//推荐列表
const recommendList = ref<any>(null)
//获取推荐列表资源
const getRecommendList = async ()=>{
  const res = await reqRecommend(pageSize.value,pageNum.value)

  recommendList.value = res.content
}

// 综合
const compRehen = async ()=>{
  await getRecommendList()
}

// 销量
const sales = (type:number)=>{
  recommendList.value.sort((a:any,b:any)=>{
    return a.algorithmSortValue/1 - b.algorithmSortValue/1
  })
}

// 浏览量
const pageView = ()=>{
  // await getRecommendList()
  recommendList.value.sort((a:any,b:any)=>{
    return a.statisticsBackup.viewCount/1 - b.statisticsBackup.viewCount/1
  })
}

// 价格由高到低
const priceUp = ()=>{
  recommendList.value.sort((a:any,b:any)=>{
    return b.initExposureNum/1 - a.initExposureNum/1
  })
}

// 价格由低到高
const priceDown = async () =>{
  recommendList.value.sort((a:any,b:any)=>{
    return a.initExposureNum/1 - b.initExposureNum/1
  })
}

// 发布时间
const releaseTime =  ()=>{
  recommendList.value.sort((a:any,b:any)=>{
    return a.updateTime/1 - b.updateTime/1
  })
}
</script>

<style scoped>

</style>
